cmake_minimum_required(VERSION 3.16)

project(codenest_service LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core LinguistTools Sql Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools Sql Network)

set(TS_FILES codenest_service_zh_CN.ts)

add_executable(codenest_service
  main.cpp
  ${TS_FILES}
  tool.h tool.cpp
  databasetool.h databasetool.cpp
  tcptool.h tcptool.cpp
  childthread.h childthread.cpp
  ctool.h ctool.cpp
)
target_link_libraries(codenest_service Qt${QT_VERSION_MAJOR}::Core Qt6::Sql Qt6::Network)

if(COMMAND qt_create_translation)
    qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
    qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()

include(GNUInstallDirs)
install(TARGETS codenest_service
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
